package com.example.concurrent.chapter02;

/**
 * @author Create By Liuqz
 * @date 2018/11/19 15:00
 */
public class DaemonThread {

    public static void main(String[] args) throws InterruptedException {

        //1.main线程开始
        Thread thread = new Thread(() -> {
            while (true) {
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });

        //2.将线程设置为守护线程
        thread.setDaemon(true);

        //3.启动线程
        thread.start();
        Thread.sleep(2_00L);
        System.out.println("Main thread finished lifecycle");
        //4.线程结束
    }
}
